package com.situ.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.situ.entily.Commodity;
import com.situ.service.CommodityService;
import com.situ.service.impl.CommodityServiceImpl;
import com.situ.util.BaseController;
import com.situ.vo.LayuiTableVO;

@WebServlet("/commodity")
public class CommodityController extends BaseController {
	private static final long serialVersionUID = 1L;

	CommodityService service = new CommodityServiceImpl();

	public void page(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.getRequestDispatcher("/WEB-INF/commodity.jsp").forward(request, response);
	}

	public LayuiTableVO list(Integer page, Integer limit, String keyword) {
		List<Commodity> list = service.all(page, limit, keyword);
		LayuiTableVO vo = new LayuiTableVO();
		vo.setCode(0);
		vo.setData(list);
		vo.setCount(service.count(keyword));
		return vo;
	}

	public List<Commodity> selall(){
		return service.selall();
	}
	
	public Commodity sel(Integer id) {

		return service.selectById(id);

	}
	
	public void save(Commodity c) {
		service.save(c);
	}
	
	public void delete(Integer id) {
		service.delete(id);
	}
	
	
	
	
	
	
	
	
	

}
